/* $Id: MapMouseListenerUnitTest.java 60 2010-02-01 19:54:35Z aaron.day $ */
package org.crazydays.gameplan.map.swing;


import java.awt.event.MouseEvent;

import org.junit.*;

import static org.easymock.EasyMock.*;
import static org.easymock.classextension.EasyMock.*;

/**
 * MapFrameMouseListenerUnitTest
 */
public class MapMouseListenerUnitTest
{
    /**
     * Test mousePressed(MouseEvent).
     */
    @Test
    public void testMousePressed()
    {
        // mocks
        JMapContextMenu contextMenu = createMock(JMapContextMenu.class);
        MouseEvent event = createMock(MouseEvent.class);
        JMapFrame mapFrame = createMock(JMapFrame.class);

        // setup
        MapMouseListener listener = new MapMouseListener();
        listener.setContextMenu(contextMenu);

        // expect
        expect(event.getButton()).andReturn(MouseEvent.BUTTON3);
        expect(event.getComponent()).andReturn(mapFrame);
        expect(event.getX()).andReturn(1);
        expect(event.getY()).andReturn(2);
        contextMenu.show(mapFrame, 1, 2);

        // replay
        replay(contextMenu, event, mapFrame);

        // test
        listener.mousePressed(event);

        // verify
        verify(contextMenu, event, mapFrame);
    }
}
